import {ElMessage, ElMessageBox} from "element-plus";

/**
 * 消息提示
 * @param msg: 消息
 * @param type: 类型
 */
export function messageTip (msg, type) {
    ElMessage({
      showClose: true,
      center: true, // 文字是否居中显示
      duration: 3000, //显示的时间，单位为毫秒，若为0则自动关闭
      message: msg,
      type: type
    })
}

export function getTokenName() {
  return "dlyk_token";
}

export function removeToken() {
  // 清理掉localStorage和sessionStorage中的token
  window.localStorage.removeItem(getTokenName());
  window.sessionStorage.removeItem(getTokenName());
}

export function messageConfirm(msg) {
  return ElMessageBox.confirm(
    msg,
    '警告',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
}